<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/29
 * Time: 8:58
 */

namespace app\admin\controller;


use think\Controller;
use think\Session;

class Common extends Controller
{
    public function init(){
   header("Content-type:text/html;charset:utf-8");
   $name=Session::get('name');
   if (!isset($name)){
       $this->error('请先登录','admin/index/login');
   }else{
       $this->checkSession();
   }
}

public function checkSession(){
        $nowtime=time();
        $l_time=Session::get('logintime');
        if ($nowtime-$l_time>20){
            Session::clear();
            Session::destroy();
            $this->error('当前用户登录超时','admin/index/login');
        }
}
}